home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / ell.lha / ell / src / ell.ast < prev    next >
Text File  |  1992-08-18  |  2KB  |  104 lines

  1. /*
  2.  *    ell2 - a redesign of ell
  3.  *
  4.  *    $RCSfile: ell.ast,v $
  5.  *    
  6.  *    purpose:    abstract syntax tree specification
  7.  *
  8.  *    $Author: grosch $
  9.  *    $Date: 1992/08/07 15:32:36 $
  10.  */
  11.  
  12. TREE IMPORT {
  13. FROM Idents    IMPORT    tIdent;
  14. FROM Sets    IMPORT    tSet;
  15. FROM StringMem    IMPORT    tStringRef;
  16. FROM Positions    IMPORT    tPosition;
  17. FROM SYSTEM    IMPORT    ADDRESS;
  18.  
  19. TYPE yyEstra = ADDRESS;
  20.  
  21. # define yyNodeHead yyEstraInfo: yyEstra; 
  22.  
  23. VAR ScannerName, ParserName: tIdent;
  24. }
  25.  
  26. GLOBAL {
  27. FROM Idents    IMPORT    WriteIdent, tIdent, MakeIdent, NoIdent;
  28. FROM Strings    IMPORT    tString, ArrayToString;
  29. FROM StringMem    IMPORT    tStringRef;
  30. FROM Positions    IMPORT    tPosition;
  31. FROM Info    IMPORT    WriteIdentSet;
  32. FROM IO        IMPORT    tFile, WriteS, WriteI;
  33.  
  34. # define writetSet(set) WriteIdentSet (yyf, set);
  35.  
  36. VAR String    : tString;
  37. }
  38.  
  39. BEGIN {
  40.    ScannerName := NoIdent;
  41.    ArrayToString ("Parser" , String); ParserName  := MakeIdent (String);
  42. }
  43.  
  44. RULE
  45.  
  46. Grammar        = sections tokens rules .
  47.  
  48. sections    = <
  49.   Sections0    = .
  50.   Sections    = sections REVERSE section .
  51. > .
  52. section        = <
  53.   Export    = codes .
  54.   Global    = codes .
  55.   Local        = codes .
  56.   Begin        = codes .
  57.   Close        = codes .
  58. > .
  59. codes        = <
  60.   Codes0    = .
  61.   Codes        = codes REVERSE code .
  62. > .
  63. Code        = [pos: tPosition] [ref: tStringRef] <
  64.   code        = .
  65. > .
  66. tokens        = <
  67.   Tokens0    = .
  68.   Tokens    = tokens REVERSE token .
  69. > .
  70. Token        = id number <
  71.   token        = .
  72. > .
  73. Id        = [pos: tPosition] [ident: tIdent] [isstring: BOOLEAN] <
  74.   id        = .
  75. > .
  76. Number        = [pos: tPosition] [value] <
  77.   number    = .
  78. > .
  79. rules        = <
  80.   Rules0    = .
  81.   Rules        = rules REVERSE rule .
  82. > .
  83. Rule        = [pos: tPosition] id codes expr -> [iscalling: BOOLEAN] <
  84.   rule        = .
  85. > .
  86. expr        = [pos: tPosition] ->
  87.           [first: tSet] [follow: tSet] [fifo: tSet] [recovery: tSet]
  88.           [length] [index] [followindex] [recindex] [expindex] <
  89.   Option    = expr .
  90.   Times        = expr .
  91.   Plus        = expr .
  92.   List        = body: expr sep: expr .
  93.   Action    = codes .
  94.   Leaf        = id -> [sure: BOOLEAN] [number] .
  95.   alternative    = -> [depth] [case: BOOLEAN] <
  96.     Alternative0= -> [recover: BOOLEAN] [default: tTree] .
  97.     Alternative    = alternative REVERSE expr .
  98.   > .
  99.   sequence    = <
  100.     Sequence0    = .
  101.     Sequence    = sequence REVERSE expr .
  102.   > .
  103. > .
  104.